﻿#pragma once

#include "MirImageControl.h"
#include <vector>
#include "../../tangible_event.h"

namespace Client::MirControls
{
    class MirAnimatedControl : public MirImageControl
    {
    public:
        static std::vector<MirAnimatedControl*> Animations;

        #pragma region Animated

    private:
        bool _animated = false;
    public:
        TangibleEvent<EventHandler> *AnimatedChanged = new TangibleEvent<EventHandler>();
        bool getAnimated() const;
        void setAnimated(bool value);
    protected:
        virtual void OnAnimatedChanged(EventArgs *e);

        #pragma endregion

        #pragma region Animation Count

    private:
        int _animationCount = 0;
    public:
        TangibleEvent<EventHandler> *AnimationCountChanged = new TangibleEvent<EventHandler>();
        virtual int getAnimationCount() const;
        virtual void setAnimationCount(int value);
    protected:
        virtual void OnAnimationCountChanged(EventArgs *e);

        #pragma endregion

        #pragma region Animation Delay

    private:
        long long _animationDelay = 0;
    public:
        TangibleEvent<EventHandler> *AnimationDelayChanged = new TangibleEvent<EventHandler>();
        long long getAnimationDelay() const;
        void setAnimationDelay(long long value);
    protected:
        virtual void OnAnimationDelayChanged();

        #pragma endregion

        #pragma region FadeIn

    private:
        long long _nextFadeTime = 0;
        bool _fadeIn = false;
    public:
        TangibleEvent<EventHandler> *FadeInChanged = new TangibleEvent<EventHandler>();
        bool getFadeIn() const;
        void setFadeIn(bool value);
    protected:
        virtual void OnFadeInChanged(EventArgs *e);

        #pragma endregion

        #pragma region FadeIn Rate

    private:
        float _fadeInRate = 0;
    public:
        TangibleEvent<EventHandler> *FadeInRateChanged = new TangibleEvent<EventHandler>();
        virtual float getFadeInRate() const;
        virtual void setFadeInRate(float value);
    protected:
        virtual void OnFadeInRateChanged(EventArgs *e);

        #pragma endregion

        #pragma region FadeIn Delay

    private:
        long long _fadeInDelay = 0;
    public:
        TangibleEvent<EventHandler> *FadeInDelayChanged = new TangibleEvent<EventHandler>();
        long long getFadeInDelay() const;
        void setFadeInDelay(long long value);
    protected:
        virtual void OnFadeInDelayChanged();

        #pragma endregion

        #pragma region Events

    public:
        TangibleEvent<EventHandler> *AfterAnimation = new TangibleEvent<EventHandler>();

        #pragma endregion

        int getIndex() const override;
        void setIndex(int value) override;

        #pragma region Loop

    private:
        bool _loop = false;
    public:
        TangibleEvent<EventHandler> *LoopChanged = new TangibleEvent<EventHandler>();
        bool getLoop() const;
        void setLoop(bool value);
    protected:
        virtual void OnLoopChanged(EventArgs *e);

        #pragma endregion

        #pragma region OffSet

    private:
        int _offSet = 0;
    public:
        TangibleEvent<EventHandler> *OffSetChanged = new TangibleEvent<EventHandler>();
        protected:
        virtual int getOffSet() const;
        public:
        virtual void setOffSet(int value);
    protected:
        virtual void OnOffSetChanged(EventArgs *e);
    private:
        long long _nextOffSet = 0;

        #pragma endregion

    public:
        MirAnimatedControl();

        void UpdateOffSet();

        #pragma region Disposable

    protected:
        void Dispose(bool disposing) override;

        #pragma endregion
    };
}
